#ifndef _UBT_STATE_TASK_EX_H_
#define _UBT_STATE_TASK_EX_H_
#include"ubt_state_types.h"
#include "ubt_state_api.h"

namespace ubt_state
{
/*链式任务*/
class CTaskEx: public ITask, ITaskCb
{
  public:
    static int ClassInit( ObstacleParams obsParams);
    static void ClassCleanup();
    static ITask *CreateTask(ITaskCb *pTaskCb, std::string taskId, std::string taskInfo, int navType);
    ~CTaskEx();
    bool Init(ITaskCb *pTaskCb, std::string taskId, std::string taskInfo, int navType);

    virtual StateStatus *GetStateStatus();
    virtual void  NotifyTaskEvent(std::string taskEvent);
    virtual void NotifyTaskStateAndStage(int state, int stage, int stateReason, std::string stateReasonDesc);



    virtual bool Start();
    virtual void Pause();
    virtual void Continue() ;
    virtual void Stop(int reason) ;
    virtual void OnTimer() ;
    virtual void OnMsg(int msgType, void *pvMsg);

    virtual ubt_task_type GetType();
    virtual ubt_task_state GetState();
    virtual ubt_task_stage GetStage();
    virtual std::string GetActionType();
    virtual void GetIndex(int& index, int& reportIndex);
    virtual void GetStopInfo(int& stopReason, std::string& stopReasonDesc);
    virtual void GetLogs(std::vector<TaskLogItem>& logs);

    void ui_state_Callback(const std_msgs::msg::String ::SharedPtr msg);

  private:
    void _StartNextTask();
    std::string _GetTaskEventByReason(int stateReason);
    ITaskCb *_pTaskCb;
    FixePathTaskInfo _taskInfo;
    ubt_task_state _state;
    int _stopReason;

    std::vector<ITask *> _pTaskArr;
    ITask *_curTask;
    int _curTaskIndex;
    
};

}
#endif


